package com.edu.juc;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int taskNum = 0;
        try {
            taskNum = scan.nextInt();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        ArrayList<int[]> list = new ArrayList<>();

        for (int i = 0; i < taskNum; i++) {
            int startTime = scan.nextInt();
            int endTime = scan.nextInt();
            int parallelism = scan.nextInt();

            list.add(new int[]{startTime, parallelism});
            list.add(new int[]{endTime, -parallelism});

        }
        Collections.sort(list,(a, b) -> {
            if (a[0] != b[0]) {
                return a[0]-b[0];
            } else {
                return a[1]- b[1];
            }
        });

        int currSrc = 0;
        int maxSrc = 0;
        for (int[] event :
                list) {
            currSrc += event[1];
            if (currSrc > maxSrc) {
                maxSrc = currSrc;
            }
        }

        System.out.println(maxSrc);
    }


}
